var $ = getApp(), methods = require("../methods.js");
Page(Object.assign({}, methods, {
	data: {
		orderid: '',
		totalprice: 0,
	},
	_onLoad: function () {
		var that = this;
		that.setData({
			orderid: that.options.orderid,
			totalprice: that.options.price
		})
	},
	formSubmit: function (e) {
		//console.log(e);return;
		var that = this;
		var orderid = that.data.orderid
		var reason = e.detail.value.reason
		var money = parseFloat(e.detail.value.money)
		if (reason == '') {
			$.alert('请填写退款原因');
			return;
		}
		if (money <= 0 || money > parseFloat(that.data.totalprice)) {
			$.alert('退款金额有误');
			return;
		}
		$.post('kanjia/refund', { orderid: orderid, reason: reason, money: money }, function (data) {
			$.alert(data.msg);
			var pages = getCurrentPages();
			if (pages.length > 1) {
				var prePage = pages[pages.length - 2];
				prePage.onLoad();
			}
			setTimeout(function () {
				$.goback();
			}, 1000);
		}, '提交中');
	}
}))